#include<bits/stdc++.h>
using namespace std;

int ret ;
int solved(int n) {
	int t = 1;
	while(n > 4) {
		n -= 3;
		t *= 3;
	}
	t *= n;
	return t;
}
signed main() {
	int n;
	cin >> n;
    ret = solved(n);
	cout << ret << '\n';
	return 0;
}
